# -*- coding: utf-8 -*-

import os, wsgiref.handlers

# Google App Engine imports.
from google.appengine.ext.webapp import util
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

# Force Django to reload its settings.
from django.conf import settings
settings._target = None

# Must set this env var before importing any part of Django
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write(_('hello'))
        #self.response.out.write('English')
        
class MainTplPage(webapp.RequestHandler):
    def get(self):
        path = os.path.join(os.path.dirname(__file__), 'templates', 'tpl.html')
        self.response.out.write(template.render(path, {}))

application = webapp.WSGIApplication([('/', MainPage),
                                      ('/tpl', MainTplPage),
                                      ], debug=True)

def main():
    # wsgiref.handlers.CGIHandler().run(application)
    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()